package com.itown.expo.service;

import java.util.Date;
import java.util.List;

import com.itown.expo.model.CcyRate;
import com.itown.expo.model.EpidemicNotify;
import com.itown.expo.model.RecordCodes;

public class SettingService extends MyBaseService {
	public RecordCodes findRecordCodeById(Long id) {
		return getRecordCodesDao().get(id);
	}

	public List<RecordCodes> findRecordCodeByCode(String code) {
		return getRecordCodesDao().findByHql(
				"from RecordCodes r where r.code=?", new Object[] { code });
	}

	public EpidemicNotify findEpidemicNotifyById(Long id) {
		return getEpidemicNotifyDao().get(id);
	}

	public RecordCodes saveRecordCode(RecordCodes r) {
		return getRecordCodesDao().save(r);
	}

	public void updateRecordCode(RecordCodes r) {
		getRecordCodesDao().merge(r);
	}

	public void deleteRecordCode(Long id) {
		getRecordCodesDao().delete(id);
	}

	public CcyRate findCcyRateById(Long id) {
		return getCcyRateDao().get(id);
	}

	public void updateCcyRate(CcyRate ccy) {
		getCcyRateDao().update(ccy);
	}

	public void deleteEpidemicNotify(Long id) {
		getEpidemicNotifyDao().delete(id);
	}

	public EpidemicNotify saveEpidemicNotify(EpidemicNotify r) {
		return getEpidemicNotifyDao().save(r);
	}

	public EpidemicNotify updateEpidemicNotify(EpidemicNotify r) {
		EpidemicNotify old = findEpidemicNotifyById(r.getId());
		old.setName(r.getName());
		old.setCountryCode(r.getCountryCode());
		old.setKind(r.getKind());
		old.setRemark(r.getRemark());
		old.setSituationCode(r.getSituationCode());
		old.setUpdateDate(new Date());
		return getEpidemicNotifyDao().update(old);
	}
}
